package com.ruicar.afs.cloud.parameter.commom.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruicar.afs.cloud.parameter.commom.condition.AddressParamCondition;
import com.ruicar.afs.cloud.parameter.commom.entity.TsysAddressParam;
import com.ruicar.afs.cloud.parameter.commom.mapper.TsysAddressParamMapper;
import com.ruicar.afs.cloud.parameter.commom.service.TsysAddressParamService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:地址区域接口实现类
 * @Author:jihuigeng
 * @Date:2020/5/13 16:57
 * @Version: V1.0
 **/
@Service
public class TsysAddressParamServiceImpl extends ServiceImpl<TsysAddressParamMapper, TsysAddressParam> implements TsysAddressParamService {

    /**
     * @param condition
     * @return
     */
    @Override
    public List getAll(AddressParamCondition condition) {
        return this.baseMapper.getLocationData(condition);
    }

    /**
     * @description: 根据编码查询
     * @author jiaqi.guo
     * @created 2020/7/9 11:20
     * @version 1.0
     */
    @Override
    public TsysAddressParam getProvinceOrCtiy(String value) {
        if (StringUtils.isNotBlank(value)) {
            return this.getOne(Wrappers.<TsysAddressParam>query().lambda()
                    .eq(TsysAddressParam::getValue, value));
        } else {
            return null;
        }
    }
}
